import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';

export enum OrderTypes {}

export enum OrderStatus {
  // 待支付
  PENDING = 'pending',
  // 已取消
  CANCELED = 'canceled',
}

export class OrderRecord {
  productId: number;
  spec: string;
  quantity: number;
  price: number;
}

export class OrderProcess {
  title: string;
  description: string;
}

@Entity('tb_order', {
  comment: '订单表',
})
export class Order {
  @PrimaryGeneratedColumn('increment', { comment: '自增主键', unsigned: true })
  id: number;

  @Column({ comment: '订单编号', unique: true })
  no: string;

  @Column({ comment: '用户ID' })
  userId: number;

  @Column({ comment: '商品金额', unsigned: true, default: 0 })
  amount: number;

  @Column({ comment: '配送金额', unsigned: true, default: 0 })
  freight: number;

  @Column({ comment: '优惠金额', unsigned: true, default: 0 })
  discount: number;

  @Column({ comment: '预付金额', unsigned: true, default: 0 })
  advance: number;

  @Column({ comment: '订单状态', default: OrderStatus.PENDING })
  status: OrderStatus;

  @Column({ comment: '订单清单', type: 'text' })
  records: JSON;

  @Column({ comment: '订单记录', type: 'text' })
  processes: JSON;
}
